package com.nyist.controller;

import com.nyist.pojo.User;
import com.nyist.result.CommonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.UUID;

@RestController
public class ProviderController {

    @Value("${server.port}")
    private String serverPort;

    //模拟数据
    public static HashMap<Integer, User> hashMap = new HashMap<>();
    static {
        hashMap.put(1,new User(1, UUID.randomUUID().toString(),10));
        hashMap.put(2,new User(2,UUID.randomUUID().toString(),20));
        hashMap.put(3,new User(3,UUID.randomUUID().toString(),30));
        hashMap.put(4,new User(4,UUID.randomUUID().toString(),40));
    }

    @GetMapping(value = "/paySQL/{id}")
    public CommonResult paySQL(@PathVariable("id") Integer id){
        User user = hashMap.get(id);
        CommonResult result=new CommonResult("200","form mysql,server.port:"+serverPort,user);
        return result;
    }


}
